import CryptoJS from 'crypto-js';

// 密钥对生成 http://web.chacuo.net/netrsakeypair

const publicKey = 'wblscjg2024ujiol'


// 加密
export function encrypt(txt) {
  var key = CryptoJS.enc.Utf8.parse(publicKey);
  var srcs = CryptoJS.enc.Utf8.parse(txt);
  var encrypted = CryptoJS.AES.encrypt(srcs, key, {mode:CryptoJS.mode.ECB,padding: CryptoJS.pad.Pkcs7});
  return encrypted.toString();
}

// 解密
export function decrypt(txt) {
  var key = CryptoJS.enc.Utf8.parse(publicKey);
  var decrypt = CryptoJS.AES.decrypt(txt, key, {mode:CryptoJS.mode.ECB,padding: CryptoJS.pad.Pkcs7});
  return CryptoJS.enc.Utf8.stringify(decrypt).toString();864467
}

